package MainPackage;

import java.util.Date;
import java.io.*;
import java.util.ArrayList;

/**
 *
 * @author Jeon
 */
public class Information implements Serializable
{
    String name;//이름
    String phoneNumber;//전화번호
    Date registeredDate;//등록일
    Date payingDay;//납부일
    int payment;//납부금
    String className;//반명
    String wayOfPayment;//납부방법

    private String studentCode;
    

	public Information()
	{
		name = null;
		phoneNumber = null;
		registeredDate = null;
		payingDay = null;
		payment = -1;
		className = null;
		wayOfPayment = null;
		studentCode = null;
	}
	
    public Information(String name, String num, Date date, Date payingDay, int money, String classname, String wayofpayment)
    {
        this.studentCode = null;
        this.name = name;
        phoneNumber = num;
        registeredDate = date;
        this.payingDay = payingDay;
        payment = money;
        className = classname;
        wayOfPayment = wayofpayment;

        studentCode = name + phoneNumber;
    }

    @Override
    public String toString()
    {
        String s1 = "name: " + name;
        String s2 = "phone number: " + phoneNumber;
        String s3 = "registered date: " + registeredDate;
        String s4 = "payment: " + payment;
        String s5 = "class name" + className;
        String s6 = "way of payment: " + wayOfPayment;

        return s1+'\n'+s2+'\n'+s3+'\n'+s4+'\n'+s5+'\n'+s6;
    }

    public void showInfo()
    {
        System.out.println(this.toString());
    }
	
	public boolean hasNullInfo()
	{
		if(name == null) return false;
		else if(phoneNumber == null) return false;
		else if(registeredDate == null) return false;
		else if(payingDay == null) return false;
		else if(payment == -1) return false;
		else if(className == null) return false;
		else if(wayOfPayment == null) return false;
		else return true;
	}

    @Override
    public int hashCode()
    {
        return studentCode.hashCode();
    }

    @Override
    public boolean equals(Object obj)
    {
        Information cmp = (Information)obj;
        if(this.studentCode.compareTo(cmp.studentCode) == 0)
            return true;
        else
            return false;   
    }   
}
